package com.thunbu.thunbu_meeting_system.dialog

import android.app.Activity
import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.lxj.xpopup.core.CenterPopupView
import com.thunbu.thunbu_meeting_system.BaseVBQuickAdapter
import com.thunbu.thunbu_meeting_system.R
import com.thunbu.thunbu_meeting_system.bean.CompanyInfo
import com.thunbu.thunbu_meeting_system.bindAdapter
import com.thunbu.thunbu_meeting_system.databinding.ItemCompanyBinding

class CompanyCheckPop(val activity: Activity, val companysInfo:List<CompanyInfo>, val func:(code:String)->Unit) : CenterPopupView(activity) {

    private lateinit var mAdapter: BaseVBQuickAdapter<CompanyInfo,ItemCompanyBinding>

    override fun getImplLayoutId(): Int {
        return R.layout.pop_company_check
    }

    override fun onCreate() {
        val rv = findViewById<RecyclerView>(R.id.rv)
        rv.layoutManager = LinearLayoutManager(activity)
        mAdapter = rv.bindAdapter { item, position ->
            tvCompany.text = item.unitName
        }
        mAdapter.setOnItemClickListener { adapter, view, position ->
            func(companysInfo[position].tenantCode)
        }
        mAdapter.setNewData(companysInfo)
    }
}